package org.absolutezero.server;

import org.jboss.logging.Logger;

import com.google.web.bindery.requestfactory.server.ExceptionHandler;
import com.google.web.bindery.requestfactory.server.RequestFactoryServlet;
import com.google.web.bindery.requestfactory.shared.ServerFailure;

public class LoggingRequestFactoryServlet extends RequestFactoryServlet
{

  static class LoquaciousExceptionHandler implements ExceptionHandler
{
    private static final Logger LOG = Logger.getLogger("Request Factory Servlet");

    @Override
    public ServerFailure createServerFailure( Throwable throwable ) {
      LOG.error( "Server error", throwable );
      return new ServerFailure( throwable.getMessage(),
    		  throwable.getClass().getName(), null, true );
    }
  }

  public LoggingRequestFactoryServlet() {
    super( new LoquaciousExceptionHandler() );
  }
}
